Objective-C

آسیب پذیری XML External Entity (XXE)

🐞 کد آسیب پذیر
// Noncompliant code
NSString *input = [request parameterForKey:@"input"];
NSLog(@"Processing input: %@", input);
// Process the input without any validation or sanitization
✅ کد اصلاح شده
// Compliant code
NSString *input = [request parameterForKey:@"input"];
NSCharacterSet *allowedCharacterSet = [NSCharacterSet alphanumericCharacterSet];
NSString *sanitizedInput = [[input componentsSeparatedByCharactersInSet:[allowedCharacterSet invertedSet]] componentsJoinedByString:@""];
NSLog(@"Processing input: %@", sanitizedInput);
// Process the sanitized input